clear
*set maxvar 32767 
*Needed packages:
*net install pretrends, from(`github'/mcaceresb/stata-pretrends/main) replace
* ssc install estout

*Set data directory
cd "C:\Users\ev42\Dropbox\ClimateStockMarket\Data\"

*Data on stock market returns
use "Securities.dta", clear
*Events data
 merge m:1 datadate using "Time.dta"
 *Firm level information
 drop _merge
merge m:1 gvkey using "Firms.dta"

encode gvkey, gen(cid)

xtset cid tid

gen returns=((prccd-l.prccd)/l.prccd)* 100
*get rid of highly unusual returns ((prccd/ ajexdi )* trfd ) /( l.prccd/ l.ajexdi )* trfd )) prior time period ]-1)*100)

gen returns2=(((prccd/ ajexdi )* trfd ) -(( l.prccd/ l.ajexdi )* l.trfd))/(( l.prccd/ l.ajexdi )* l.trfd)*100

drop if abs(returns)>50

drop if abs(returns2)>50


gen brown=0
replace brown=1 if CoalCU==1 | OilCU==1
rename renew2 renewables

label define neglab 1 "Plan B Earth1" 2 "Swiss Senior Women1" 3 "Plan B Earth2" 4 "Friends Irish Environment" 5 "Family Farmers v Germany" 6 "Swiss Senior Women2" 7 "Parliamentarians v France" 8 "Plan B Earth3"

label define poslab 1 "Urgenda1" 2 "Urgenda2" 3 "Urgenda3" 4 "Friends Irish Environment" 5 "Commune de Grande-Synthe" 6 "Notre Affaire à Tous1" 7 "Neubauer" 8 "Greenpeace1 v Spain" 9 "Klimaatzaak v Belgium" 10 "Commune de Grande-Synthe2" 11 "Greenpeace2 v Spain" 12 "Greenpeace3 v Spain" 13 "Notre Affaire à Tous2"

label values negative neglab
label values positive poslab


set emptycells drop
gen home=0
replace home=1 if CTCountry==fic

*Alternative definition of home country for stock exchange
gen home2=home
replace home2=1 if CTCountry=="NLD" & NLDc==1
replace home2=1 if CTCountry=="DEU" & DEUc==1
replace home2=1 if CTCountry=="GBR" & GBRc==1
replace home2=1 if CTCountry=="FRA" & FRAc==1
replace home2=1 if CTCountry=="ESP" & ESPc==1
replace home2=1 if CTCountry=="BEL" & BELc==1
replace home2=1 if CTCountry=="CHE" & CHEc==1
replace home2=1 if CTCountry=="IRL" & IRLc==1

gen tid2=tid^2
gen tid3=tid^3

gen ATEhomep=0
replace ATEhomep=1 if pos==1 & home==1
label variable ATEhomep "Home country, win"

gen ATEhomen=0
replace ATEhomen=1 if neg==1 & home==1
label variable ATEhomen "Home country, loss"
label variable pos "Plaintiff win"
label variable neg "Plaintiff loss"

  gen ATEhomep2=0
replace ATEhomep2=1 if pos==1 & home==1
label variable ATEhomep2 "Home country, win"

gen ATEhomen2=0
replace ATEhomen2=1 if neg==1 & home==1
label variable ATEhomen2 "Home country, loss"
label variable pos "Plaintiff win"
label variable neg "Plaintiff loss"

gen year=year(datadate)
drop if year==2022

gen renewl=renewables
replace renewl=0 if marketvalue < 1000000000

*gen renewables2=0
*replace renewables2=1 if SEC=="RWD" | SEC=="RBB" | SEC=="RSR"

drop if abs(returns)>12
 gen EU=1
 replace EU=0 if fic=="GBR" | fic== "CHE" | fic== "NOR"

xtset cid tid
sort cid tid

*redefine event day as just eventN
gen posj=pos
replace posj=0 if dpos==1

   gen month=month(datadate)
   gen dayofweek=dow(datadate)
*look at days before and after event

gen pday=-11
replace pday=dpos if dpos<4
replace pday=-1 if pday==-11 & f.dpos==0
replace pday=-2 if pday==-11 & f2.dpos==0
replace pday=-3 if pday==-11 & f3.dpos==0
replace pday=-4 if pday==-11 & f4.dpos==0
replace pday=-5 if pday==-11 & f5.dpos==0
replace pday=-6 if pday==-11 & f6.dpos==0
replace pday=-7 if pday==-11 & f7.dpos==0
replace pday=-8 if pday==-11 & f8.dpos==0
replace pday=-9 if pday==-11 & f9.dpos==0
replace pday=-10 if pday==-11 & f10.dpos==0

replace pday=pday+11
label define day 0 "ref" 1 "-10" 2 "-9" 3 "-8" 4 "-7" 5 "-6" 6 "-5" 7 "-4" 8 "-3" 9 "-2" 10 "-1" 11 "0" 12 "1" 13 "2" 14 "3"  
label values pday day

*Create dummies for Roth test
 foreach i of num 1/14 {
 gen day`i'=0
 replace day`i'=1 if pday == `i'
  }

*Bringing in event datadate  *Controlling for events
  drop _merge
  merge 1:1 gvkey datadate using "AnnouncementsShort.dta"

drop if _merge==2

drop _merge

xtset cid tid
sort cid tid

replace eventN=0 if eventN==.
replace eventN=0 if (pos==0 & neg==0) & (f.pos==0 & f.neg==0)

gen linear=(year-2014)*month
gen quadr=linear^2


*Set Output directory
cd "C:\Users\ev42\Dropbox\Apps\Overleaf\ClimateLitigation\"


  est clear


*Overall Effects
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid##c.mktrf i.cid##c.smb i.cid##c.hml i.cid##c.brentp i.year##c.month##i.cid if renewables==1 ,  fe robust cluster(cid) 
  estimates store Renewables
    estimates store Renewables
   predict res, residuals 
 qnorm res, title ("Q-Q plot Renewables")
  graph export QQRenew.png, replace
  
  drop res
  
  quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen i.cid##c.mktrf i.cid##c.smb i.cid##c.hml i.cid##c.brentp i.year##c.month##i.cid if renewl==1 ,  fe robust cluster(cid) 
  estimates store RenewablesLarge
    predict res, residuals 
 qnorm res, title ("Q-Q plot Renewables, Large")
  graph export QQRenew.png, replace
  
  drop res
 
 quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid##c.mktrf i.cid##c.smb i.cid##c.hml i.cid##c.brentp i.year##c.month##i.cid if green==1 ,  fe robust cluster(cid) 
  estimates store Green
   
   predict res, residuals 
 qnorm res, title ("Q-Q plot Green")
  graph export QQGreen.png, replace
  
  drop res
 
 quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid##c.mktrf i.cid##c.smb i.cid##c.hml i.cid##c.brentp i.year##c.month##i.cid if OilCU==1 ,  fe robust cluster(cid) 
  estimates store Oil
       predict res, residuals 
 qnorm res, title ("Q-Q plot Oil")
  graph export QQOil.png, replace
  
 
 drop res
 
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid##c.mktrf i.cid##c.smb i.cid##c.hml i.cid##c.brentp i.year##c.month##i.cid if CoalCU==1 ,  fe robust cluster(cid) 
  estimates store Coal
  
   predict res, residuals 
 qnorm res, title ("Q-Q plot Coal")
  graph export QQCoal.png, replace
  
 
 *Plot
 coefplot Renewables Green Oil Coal,  keep(pos ATEhomep neg ATEhomen) scheme(s1mono) xline(0) legend(position(6) rows(1) ) note("Bars indicate 95% confidence intervals")
 graph export Overall.png, replace
 
 *Table
   
 esttab using "regression1.tex", replace  ///
  keep(pos ATEhomep neg ATEhomen) ///
 b(2) se(2) nomtitle label star(* 0.10 ** 0.05 *** 0.01) ///
 booktabs  ///
   mgroups("Renewables" "Renewables, large firms" "Green" "Oil/Gas" "Coal", pattern(1 1 1 1 1 )  prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) ) ///
 title(Overall effects of positive and negative rulings  \label{reg1}) 
 
 
 est clear
 
 
 *Arch/Garch Models
 

 quietly eststo: arch returns2 pos ATEhomep neg ATEhomen mktrf smb hml brentp linear quadr if renewables==1, arch(1/2) garch(1/2) vce(robust)
  estimates store Renewables

  
 quietly eststo: arch returns2 pos ATEhomep neg ATEhomen mktrf smb hml brentp linear quadr if renewl==1 ,  arch(1/2) garch(1/2) vce(robust)
  estimates store RenewablesLarge
 
 
 quietly eststo: arch returns2 pos ATEhomep neg ATEhomen mktrf smb hml brentp linear quadr if green==1 ,  arch(1/2) garch(1/2) vce(robust)
  estimates store Green
   
 
 quietly eststo: arch returns2 pos ATEhomep neg ATEhomen mktrf smb hml brentp linear quadr  if OilCU==1 , arch(1/2) garch(1/2) vce(robust)
  estimates store Oil
  
 
 quietly eststo: arch returns2 pos ATEhomep neg ATEhomen mktrf smb hml brentp linear quadr  if CoalCU==1 ,  arch(1/2) garch(1/2) vce(robust)
  estimates store Coal
  
 
 *Plot
 coefplot Renewables Green Oil Coal, title("Arch/Garch estimates")  keep(pos ATEhomep neg ATEhomen) scheme(s1mono) xline(0) legend(position(6) rows(1) ) 
 graph export OverallArch.png, replace
 
 *Table
   
 esttab using "regression1Arch.tex", replace  ///
 b(2) se(2) nomtitle label star(* 0.10 ** 0.05 *** 0.01) ///
 booktabs  ///
   mgroups("Renewables" "Renewables, large firms" "Green" "Oil/Gas" "Coal", pattern(1 1 1 1 1 )  prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) ) ///
 title(Overall effects of positive and negative rulings, ARCH/GARCH  \label{reg2}) 
 
 
 
 
 est clear
 
 
 
 
 
 
 *Overall Effects, alternative definition home country
quietly eststo: xtreg returns2 pos ATEhomep2 neg ATEhomen2  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp if renewables==1 ,  fe robust cluster(cid) 
estimates store Renewables
  quietly eststo: xtreg returns2 pos ATEhomep2 neg ATEhomen2  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp if renewl==1 ,  fe robust cluster(cid) 
 estimates store  RenewablesLarge
 quietly eststo: xtreg returns2 pos ATEhomep2 neg ATEhomen2  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp if green==1 ,  fe robust cluster(cid)  
   estimates store Green 
 
 
 quietly eststo: xtreg returns2 pos ATEhomep2 neg ATEhomen2  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp if OilCU==1 ,  fe robust cluster(cid) 
  estimates store Oil
 
quietly eststo: xtreg returns2 pos ATEhomep2 neg ATEhomen2  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp if CoalCU==1 ,  fe robust cluster(cid) 
  estimates store Coal
 

 *Table
   
 esttab using "regression2.tex", replace  ///
  keep(pos ATEhomep2 neg ATEhomen2) ///
 b(2) se(2) nomtitle label star(* 0.10 ** 0.05 *** 0.01) ///
 booktabs  ///
   mgroups("Renewables" "Renewables, large firms" "Green" "Oil/Gas" "Coal", pattern(1 1 1 1 1 )  prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) ) ///
 title(Overall effects of positive and negative rulings, home country defined by stock market  \label{reg2}) 
 
 
 est clear
 
 
 *Estimates controlling for events
 
   *Controlling for events


quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp  i.eventN  if renewables==1 ,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp  i.eventN  if renewl==1 ,  fe robust cluster(cid)  
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp i.eventN  if green==1 ,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp  i.eventN  if OilCU==1 ,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp i.eventN  if CoalCU==1 ,  fe robust cluster(cid) 

 
 *Table
   
 esttab using "regression3.tex", replace  ///
  keep(pos ATEhomep neg ATEhomen) ///
 b(2) se(2) nomtitle label star(* 0.10 ** 0.05 *** 0.01) ///
 booktabs  ///
   mgroups("Renewables" "Renewables, large firms" "Green" "Oil/Gas" "Coal", pattern(1 1 1 1 1 )  prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) ) ///
 title(Overall effects of positive and negative rulings, controlling for events  \label{reg2}) 
 
 
 est clear
 
 
 
* Per ruling estimates Renewables

 quietly eststo: xtreg returns2 i.positive i.negative i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp if renewables==1 , fe robust cluster(cid) 

  coefplot , keep(*.positive) scheme(s1mono) xline(0)
  
  graph export RenewPos2.png, replace


 quietly eststo: xtreg returns2 i.positive i.negative i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp if renewl==1 , fe robust cluster(cid) 

  coefplot , keep(*.positive) scheme(s1mono) xline(0)
  
  graph export RenewPosLarge.png, replace
 
  
 esttab using "regression4.tex", replace  ///
  keep( *.positive) ///
 b(2) se(2) nomtitle label star(* 0.10 ** 0.05 *** 0.01) ///
 booktabs  ///
   mgroups("Renewables" "Renewables, large", pattern(1 1 )  prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) ) ///
 title(Ruling specific effects of positive rulings  \label{reg2}) 
 
  
  est clear
 
 *Event plot
 * i.year##c.month##i.cid
 
      quietly: xtreg returns2  i.pday i.cid##c.mktrf i.cid##c.smb i.cid##c.hml i.cid##c.brentp i.year##c.month##i.cid     if renewables==1 , fe vce(cluster cid) 
      estimates store Renewables
	      quietly: xtreg returns2  i.pday i.cid##c.mktrf i.cid##c.smb i.cid##c.hml i.cid##c.brentp i.year##c.month##i.cid  if renewl==1 , fe vce(cluster cid) 
      estimates store RenewablesLarge
	       quietly: xtreg returns2 i.pday i.cid##c.mktrf i.cid##c.smb i.cid##c.hml i.cid##c.brentp i.year##c.month##i.cid if CoalCU==1 , fe robust cluster(cid) 
    estimates store Coal
	  

coefplot Coal Renewables RenewablesLarge, vertical  keep(*.pday) ///
         xtitle("Days Before and After Rulings") xscale(titlegap(2))  ///
note("OLS coefficient estimates (and their 95% confidence intervals) are reported." ///
          "Model includes company specific 3 Fama French factors, oil price.)",  margin(small)) ///
graphregion(fcolor(white) lcolor(white) lwidth(vvvthin) ifcolor(white) ilcolor(white)  ///
ilwidth(vvvthin)) ciopts(lwidth(*3))  

 graph export Days.png, replace
	
 *Table
   
 esttab Renewables RenewablesLarge Coal using "regressionDays.tex", replace  ///
  keep(*.pday) ///
 b(2) se(2) nomtitle label star(* 0.10 ** 0.05 *** 0.01) ///
 booktabs  ///
   mgroups("Renewables" "Renewables, large firms" "Coal", pattern(1 1 1 )  prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) ) ///
 title(Daily Effects of Positive Judgments  \label{reg2}) 
 
 
 est clear
	
	
	
  est clear
 
 
 
 *Roth test Renewables 
 
   quietly: xtreg returns2 day7-day14 i.cid##c.mktrf i.cid##c.smb i.cid##c.hml i.cid##c.brentp i.year##c.month##i.cid    if renewables==1 , fe robust cluster( cid) 
 pretrends power 0.5, pre(1/4) post(5/8)
   pretrends power 0.8, pre(1/4) post(5/8)
 
    quietly: xtreg returns2 day7-day14 i.cid##c.mktrf i.cid##c.smb i.cid##c.hml i.cid##c.brentp i.year##c.month##i.cid    if renewl==1 , fe robust cluster( cid) 
 pretrends power 0.5, pre(1/4) post(5/8)
   pretrends power 0.8, pre(1/4) post(5/8)
   
      quietly: xtreg returns2 day7-day14 i.cid##c.mktrf i.cid##c.smb i.cid##c.hml i.cid##c.brentp i.year##c.month##i.cid    if CoalCU==1 , fe robust cluster( cid) 
 pretrends power 0.5, pre(1/4) post(5/8)
   pretrends power 0.8, pre(1/4) post(5/8)

 
 *Q-Q plot

   quietly: xtreg returns2 pos ATEhomep neg ATEhomen i.cid##c.mktrf i.cid##c.smb i.cid##c.hml i.cid##c.brentp i.year##c.month##i.cid    if renewables==1 , fe robust cluster( cid) 
 predict resi, residuals 
 qnorm resi, title ("Q-Q plot Renewables")
  graph export QQRenew.png, replace
 
 drop resi
 
  quietly: xtreg returns2 pos ATEhomep neg ATEhomen i.cid##c.mktrf i.cid##c.smb i.cid##c.hml i.cid##c.brentp i.year##c.month##i.cid    if renewl==1 , fe robust cluster( cid) 
 predict resi, residuals 
 qnorm resi, title ("Q-Q plot Large Renewables")
  graph export QQRenewL.png, replace
 
 drop resi
   quietly: xtreg returns2 pos ATEhomep neg ATEhomen i.cid##c.mktrf i.cid##c.smb i.cid##c.hml i.cid##c.brentp i.year##c.month##i.cid    if CoalCU==1 , fe robust cluster( cid) 
 predict resi, residuals 
 qnorm resi, title ("Q-Q plot Coal")
  graph export QQCoal.png, replace
  
    quietly: xtreg returns2 pos ATEhomep neg ATEhomen i.cid##c.mktrf i.cid##c.smb i.cid##c.hml i.cid##c.brentp i.year##c.month##i.cid    if green==1 , fe robust cluster( cid) 
 predict renew, residuals 
 qnorm renew, title ("Q-Q plot Green")
  graph export QQGreen.png, replace
  
  drop renew
  
    quietly: xtreg returns2 pos ATEhomep neg ATEhomen i.cid##c.mktrf i.cid##c.smb i.cid##c.hml i.cid##c.brentp i.year##c.month##i.cid    if OilCU==1 , fe robust cluster( cid) 
 predict renew, residuals 
 qnorm renew, title ("Q-Q plotOil")
  graph export QQOil.png, replace
  
  
 
  *Robustness to including lagged returns
  
  
     *Controlling for events
quietly eststo: xtreg returns2 l.returns2 l2.returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp    if renewables==1 ,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 l.returns2 l2.returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp    if renewl==1 ,  fe robust cluster(cid)  
quietly eststo: xtreg returns2 l.returns2 l2.returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp  if green==1 ,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 l.returns2 l2.returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp   if OilCU==1 ,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 l.returns2 l2.returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp   if CoalCU==1 ,  fe robust cluster(cid) 

 
 *Table
   
 esttab using "regression5.tex", replace  ///
  keep(*.returns2 pos ATEhomep neg ATEhomen) ///
 b(2) se(2) nomtitle label star(* 0.10 ** 0.05 *** 0.01) ///
 booktabs  ///
   mgroups("Renewables" "Renewables, large firms" "Green" "Oil/Gas" "Coal", pattern(1 1 1 1 1 )  prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) ) ///
 title(Overall effects of positive and negative rulings, controlling for lagged returns  \label{reg2}) 
 
 
 est clear
  
  
 *Estimates controlling for events
 
   *Controlling for events


quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp    if renewables==1 & year>2017 ,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp    if renewl==1 & year>2017 ,  fe robust cluster(cid)  
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp   if green==1 & year>2017,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp   if OilCU==1 & year>2017 ,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp   if CoalCU==1 & year>2017 ,  fe robust cluster(cid) 

 
 *Table
   
 esttab using "regression6.tex", replace  ///
  keep(pos ATEhomep neg ATEhomen) ///
 b(2) se(2) nomtitle label star(* 0.10 ** 0.05 *** 0.01) ///
 booktabs  ///
   mgroups("Renewables" "Renewables, large firms" "Green" "Oil/Gas" "Coal", pattern(1 1 1 1 1 )  prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) ) ///
 title(Overall effects of positive and negative rulings, s2018-2021 period  \label{reg2}) 
 
 
 est clear
  
  
  
 *Estimates controlling for events
 
   *Excluding oil prices


quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml   if renewables==1 ,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml   i.eventN  if renewl==1 ,  fe robust cluster(cid)  
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml  i.eventN  if green==1 ,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml   i.eventN  if OilCU==1 ,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.cid#c.mktrf i.cid#c.smb i.cid#c.hml  if CoalCU==1 ,  fe robust cluster(cid) 

 
 *Table
   
 esttab using "regression7.tex", replace  ///
  keep(pos ATEhomep neg ATEhomen) ///
 b(2) se(2) nomtitle label star(* 0.10 ** 0.05 *** 0.01) ///
 booktabs  ///
   mgroups("Renewables" "Renewables, large firms" "Green" "Oil/Gas" "Coal", pattern(1 1 1 1 1 )  prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) ) ///
 title(Overall effects of positive and negative rulings, excluding oil prices from analysis  \label{reg2}) 
 
 
 est clear
 
 *Estimates controlling for events
 
   *Controlling for events


quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.year#i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp    if renewables==1  ,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.year#i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp    if renewl==1  ,  fe robust cluster(cid)  
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.year#i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp   if green==1 ,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.year#i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp   if OilCU==1  ,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.year#i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp   if CoalCU==1 ,  fe robust cluster(cid) 

 
 *Table
   
 esttab using "regression8.tex", replace  ///
  keep(pos ATEhomep neg ATEhomen) ///
 b(2) se(2) nomtitle label star(* 0.10 ** 0.05 *** 0.01) ///
 booktabs  ///
   mgroups("Renewables" "Renewables, large firms" "Green" "Oil/Gas" "Coal", pattern(1 1 1 1 1 )  prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) ) ///
 title(Overall effects of positive and negative rulings, market rate firm dummies interacted with year  \label{reg2}) 
  

  
   *Estimates controlling for events
 
   *Controlling for events
 est clear

quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.year#i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp    if renewables==1 & EU==1 ,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.year#i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp    if renewl==1 & EU==1 ,  fe robust cluster(cid)  
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.year#i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp   if green==1 & EU==1,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.year#i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp   if OilCU==1 & EU==1  ,  fe robust cluster(cid) 
quietly eststo: xtreg returns2 pos ATEhomep neg ATEhomen  i.year#i.cid#c.mktrf i.cid#c.smb i.cid#c.hml i.cid#c.brentp   if CoalCU==1 & EU==1 ,  fe robust cluster(cid) 

 
 *Table
   
 esttab using "regression9.tex", replace  ///
  keep(pos ATEhomep neg ATEhomen) ///
 b(2) se(2) nomtitle label star(* 0.10 ** 0.05 *** 0.01) ///
 booktabs  ///
   mgroups("Renewables" "Renewables, large firms" "Green" "Oil/Gas" "Coal", pattern(1 1 1 1 1 )  prefix(\multicolumn{@span}{c}{) suffix(}) span erepeat(\cmidrule(lr){@span}) ) ///
 title(Overall effects of positive and negative rulings, only EU firms  \label{reg2}) 
  
  
  
  *Summary table
  
  collapse returns2 marketvalue cshtrd DEU GBR FRA NLD renewables green OilCU CoalCU, by (cid)

foreach i of varlist returns2-NLD  {
local a : variable label `i'
local a: subinstr local a "(mean) " ""
label var `i' "`a'"
}

label variable returns2 "Daily Returns"
label variable cshtrd "Daily Trading Volume"
label variable marketvalue "Market Value"
label variable DEU "Frankfurt"
label variable GBR "London"
label variable FRA "Paris"
label variable NLD "Amsterdam"


  est clear
eststo grp1: estpost summ  returns2 marketvalue cshtrd DEU GBR FRA NLD if renewables==1
eststo grp2: estpost summ  returns2 marketvalue cshtrd DEU GBR FRA NLD  if green==1
eststo grp3: estpost summ  returns2 marketvalue cshtrd DEU GBR FRA NLD  if OilCU==1
eststo grp4: estpost summ  returns2 marketvalue cshtrd DEU GBR FRA NLD  if CoalCU==1
esttab grp*,  cells("mean(fmt(%6.2fc)) sd  count(fmt(0))")  mtitle("Renewables" "Green" "Oil/Gas" "Coal")

 
esttab grp* using "summarytable.tex", replace ///
   cells("mean(fmt(%6.2fc))")  nostar nonumber unstack ///
   compress nonote noobs gap label booktabs    ///
    mtitle("Renewables" "Green" "Oil/Gas" "Coal")
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  